package com.traffic.between.redis.running;

import org.apache.log4j.Logger;

import com.traffic.between.annotation.ProvinderChoose;
import com.traffic.between.config.OrderInfoContext;
import com.traffic.between.redis.Redis;
import com.traffic.between.util.DictConstantKeys;
import com.traffic.between.util.OrderUtils;
import com.traffic.managent.service.order.bean.OrderBean;

/**
 * 接收订购中的订单
 * 
 */
public class BsmOrderStatusWorker implements Runnable, OrderUtils {

	private static Logger logger = Logger.getLogger(BsmOrderStatusWorker.class);

	public void run() {
		while (true) {
			String orderId = "";
			try {
				OrderBean order = Redis.use(DictConstantKeys.redis_order_name).blpop(OrderUtils.ORDER_LIST_STATUS);
				if (order != null) {
					orderId = order.getIds();
					OrderInfoContext.putContext(order);
					logger.info("BsmOrderStatusWorker get to redis order id:" + order.getIds() + ",phoneNo:"
							+ order.getPhoneNo());
					ProvinderChoose.service.statusInvoke(order.getChannel());
				}
			} catch (Exception e) {
				e.printStackTrace();
				logger.error("线程处理队列中订单ID为" + orderId + "异常" + e);
			}
		}
	}
}
